package cn.itcast.web.exception;

import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class GlobalExceptionControllerAdvice {

    @ExceptionHandler(Exception.class)
    public String handlerException(Exception e) {
        System.out.println("springMVC捕获了异常：" + e.getMessage());
        return "error";
    }


    // 专门捕获shiro注解方案权限不足异常，跳转到提示页面
    @ExceptionHandler(UnauthorizedException.class)
    public String handlerUnauthorizedException(){
        return "redirect:/unauthorized.jsp";
    }
}
